package main

import (
	"fmt"
	"time"
)

func main() {
	t := costTime(test, "aaa")
	fmt.Println(t.Seconds())
}

func costTime(f decFunc, s string) time.Duration {
	start := time.Now()
	f(s)
	end := time.Now()
	ret := end.Sub(start)
	return ret
}

type decFunc func(string) string

func test(s string) string {
	time.Sleep(time.Second * 2)
	return s + "666"
}
